package com.ruoyi.exam.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import javax.annotation.Resource;
import java.util.List;
import com.ruoyi.common.result.Result;

import com.ruoyi.exam.service.IExamPaperQuestionCustomerAnswerService;
import com.ruoyi.exam.domain.ExamPaperQuestionCustomerAnswer;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 试卷题目答案表 前端控制器
 * </p>
 *
 * @author JY
 * @since 2024-02-26
 */
@Api(tags = "试卷题目答案表表")
@RestController
@RequestMapping("/exam/exam-paper-question-customer-answer")
    public class ExamPaperQuestionCustomerAnswerController {
@Resource(name="ExamPaperQuestionCustomerAnswerServiceImpl")
private IExamPaperQuestionCustomerAnswerService examPaperQuestionCustomerAnswerService;

/**
* 新增
*/
@PostMapping("/save")
@ApiOperation(value = "新增",notes = "新增")
@ApiImplicitParam(name = "examPaperQuestionCustomerAnswer" ,value = "examPaperQuestionCustomerAnswer实体类",dataTypeClass = String.class)
public Result<Boolean> insert(@RequestBody ExamPaperQuestionCustomerAnswer examPaperQuestionCustomerAnswer) {
        return Result.ok(examPaperQuestionCustomerAnswerService.save(examPaperQuestionCustomerAnswer));
        }

/**
* 修改
*/
@PostMapping("/update")
@ApiOperation(value = "修改",notes = "修改")
@ApiImplicitParam(name = "examPaperQuestionCustomerAnswer" ,value = "examPaperQuestionCustomerAnswer实体类",dataTypeClass = String.class)
public Result<Boolean>  update(@RequestBody ExamPaperQuestionCustomerAnswer examPaperQuestionCustomerAnswer) {
        return Result.ok(examPaperQuestionCustomerAnswerService.updateById(examPaperQuestionCustomerAnswer));
        }

/**
* 根据id删除
*/
@PostMapping("/delete/{id}")
@ApiOperation(value = "根据id删除",notes = "根据id删除")
@ApiImplicitParam(name = "id" ,value = "id",dataTypeClass = Integer.class)
public Result<Boolean>  delete(@PathVariable Integer id) {
        return Result.ok(examPaperQuestionCustomerAnswerService.removeById(id));
        }

/**
* 批量删除
*/
@PostMapping("/del/batch")
@ApiOperation(value = "批量删除",notes = "批量删除")
@ApiImplicitParam(name = "ids" ,value = "id数组",dataTypeClass = Integer.class)
public Result<Boolean>  deleteBatch(@RequestBody List<Integer> ids) {
        return Result.ok(examPaperQuestionCustomerAnswerService.removeByIds(ids));
        }

/**
* 查询全部
*/
@GetMapping("/getAll")
@ApiOperation(value = "查询全部",notes = "查询全部")
public Result<List<ExamPaperQuestionCustomerAnswer>> findAll() {
        return Result.ok(examPaperQuestionCustomerAnswerService.list());
        }

/**
* 根据id查询一个
*/
@GetMapping("getById/{id}")
@ApiOperation(value = "根据id查询一个",notes = "根据id查询一个")
@ApiImplicitParam(name = "id" ,value = "id",dataTypeClass = Integer.class)
public Result<ExamPaperQuestionCustomerAnswer> findOne(@PathVariable Integer id){
        return Result.ok(examPaperQuestionCustomerAnswerService.getById(id));
        }

/**
* 分页模糊查询
*/
@GetMapping("/get/page")
@ApiOperation(value = "分页模糊查询",notes = "分页模糊查询")
public Result<Page<ExamPaperQuestionCustomerAnswer>> findPage(@RequestParam Integer pageNum,
@RequestParam Integer pageSize) {
        QueryWrapper<ExamPaperQuestionCustomerAnswer> queryWrapper = new QueryWrapper<>();
        // 倒序查询
        queryWrapper.orderByDesc("id");
        return Result.ok(examPaperQuestionCustomerAnswerService.page(new Page<>(pageNum, pageSize),queryWrapper));
        }
        }

